package chaoyue.study.config;

import chaoyue.study.interceptor.MyRestTemplateInterceptor;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

@Configuration
public class RestTemplateConfig {
    /**
     * 通过 RestTemplateBuilder 构建 HttpClient
     */
    @Bean
    public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) {
        return restTemplateBuilder
                .interceptors(new MyRestTemplateInterceptor()) // 添加自定义的拦截器
                .build();
    }
}
